package com.revoltingdevelopment.perquackey;

class Die {
    
    //======================================================= instance variables
    private int _faceValue;     // value that shows on face of die
    
    //============================================================== constructor
    public Die() {
        roll();  // Set to random initial value
    }
    
    //============================================================== method roll
    /** Produce random roll in range 1-6. 
     * @return Result of roll (1-6).
     */
    public int roll() {
    int val = (int)(6*Math.random() + 1);   // Range 1-6
	setValue(val);
        return val;
    }

/** Sets the value of the Die.  
     * @param spots Number from 1-6.
     */
    public void setValue(int spots) {
        _faceValue = spots;
    }
    //========================================================== method getValue
    /** Returns result of last roll.*/
    public int getValue() {
        return _faceValue;
    }
}

